/*
 *
 * @ProjectName:    my_umi_app
 * @Package:
 * @ClassName:      blogger
 * @Description:
 * @Author:         SuPeiSen
 * @CreateDate:     2021/3/4 2:32 下午
 * @UpdateDate:     2021/3/4 2:32 下午
 * @UpdateRemark:   更新说明：
 * @Version:        1.0
 */

import React, { useEffect, useState } from 'react';
import { BlogGetBloggerInfoApi } from '@/service/blog/blog_setting_api';
import { LoadingWidget } from '@/widget/loading_wdiget/loading_widget';
import { articleContentImage } from '@/utils/app_fun';
import './style/blogger_style.less';

export default () => {
  const [bloggerContent, setBloggerContent] = useState<string>('');
  const [loading, setLoading] = useState<boolean>(true);

  useEffect(() => {
    BlogGetBloggerInfoApi()
      .then((model) => {
        if (model.success) {
          setBloggerContent(model.data!.data.blogger_content);
        }
      })
      .finally(() => setLoading(false));
  }, []);

  return loading ? (
    LoadingWidget()
  ) : (
    <div className={'blogger_main'}>
      {/*富文本*/}
      <div
        style={{ width: '90%', margin: '0 auto', paddingTop: '3%' }}
        dangerouslySetInnerHTML={{
          __html: articleContentImage(bloggerContent),
        }}
      />
    </div>
  );
};
